/*
 * @Author: lijunqing
 * @Date: 2024-04-18 09:47:17
 * @LastEditors: lijunqing
 * @LastEditTime: 2024-04-18 10:02:21
 * @Description: 
 */
const http = require("http");

// 创建一个对应的服务器
const server = http.createServer((rqs, res) => {
  const url = rqs.url;
  const method = rqs.method;
  switch (url) {
    case "/login":
      if (method === "POST") {
        res.end("登录成功~");
      } else {
        res.end("不支持的请求方式, 请检测你的请求方式~");
      }
      break;
    case "/products":
      res.end("商品列表~");
      break;
  }
});

// 开启一个服务器端口 1024 - 66535
server.listen("8000", () => {
  console.log("服务器开启成功");
});
